<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">

<!-- 导航栏 -->
<nav th:fragment="header" class="navbar sticky-top navbar-expand-lg navbar-light"
     style="background-color: #ffffff;box-shadow: 0px -2px 10px #d0cccc;">
  <div class="container">
    <!--标题-->
    <a class="navbar-brand">
      简易在线聊天
    </a>
    <!-- 导航  -->
    <div class="navbar float-right" style="padding: 0">
      <!--如果已登录-->
      <ul class="navbar-nav mr-auto ">
          <li class="dropdown">
            <a  style="color: rgba(0,0,0,.5);text-decoration: none" class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              <img th:src="${session.loginUser.getAvatar()}" style="width: 30px;height:30px;border-radius: 50%;" alt="">
              <span sec:authentication="name"></span>
              <!--<span th:text="${session.SPRING_SECURITY_CONTEXT.authentication.principal.username}"></span>-->
            </a>
            <div class="dropdown-menu" aria-labelledby="navbarDropdown">
              <a class="dropdown-item" th:href="@{/tochat}">在线聊天</a>
              <div class="dropdown-divider"></div>
              <a class="dropdown-item" th:href="@{/logout}">注销</a>
            </div>
          </li>
      </ul>
    </div>

  </div>
</nav>


</html>